import Taro, {Component} from '@tarojs/taro'

import {View,Picker,Text} from "@tarojs/components"
import {AtList, AtListItem, AtIcon, AtButton} from "taro-ui"
import './index.scss'
import {getFiles} from "./service";
import {getHomework} from "../classHomework/service";

export default class Index extends Component {
    constructor(props) {
        super(props);
        this.state = {
            current: 0,
            selector:['全部','DOC','PPT','PDF','XLS'],
            selectorChecked:'全部',
          title: '',
          json: [{'title': 'myTitle' },
            {'title': 'my2Title' }]
        }
    }
  componentWillMount(){
    this.getjson()
  }
  async getjson(){
    await getFiles().then(res=>{
      this.setState({
        json: res.data
      })
    })
  }
  onChange = e => {
    this.setState({
      selectorChecked: this.state.selector[e.detail.value]
    })
  }
  Submit(){
      getFiles()
  }
    render() {

        return (
            <View>
              <View className='selectorChecked'>
                <Picker mode='selector'
                        range={this.state.selector}
                        onChange={this.onChange}
                >
                  <View className='pickerItem'>
                    <AtIcon prefixClass='icon' value='guolv' size='25' color='#719BEA'></AtIcon>
                    <Text> {this.state.selectorChecked}</Text>
                    <View className='icon_2'>
                      <AtIcon   value='chevron-down' size='25' color='#CCCCCC'></AtIcon>
                    </View>

                  </View>
                </Picker>
              </View>
              <View>
                <AtList>
                  {
                    this.state.json.map((item,index)=>{
                      return (
                        <AtListItem
                          title={item.title}
                          extraText='详细信息'
                          arrow='right'
                          iconInfo={{ size: 25, color: '#FF4949', value: 'download-cloud', }}
                        />
                      )
                    })
                  }
                </AtList>
              </View>
            </View>
        )
    }

}
